﻿using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.Common;
using HumanManagement.BusinessObjects;
using HumanManagement.DataAccess;

namespace HumanManagement.BusinessLogic
{
	public class ContractTypeBL
	{

		#region ***** Init Methods ***** 
		ContractTypeDA objContractTypeDA;
		public ContractTypeBL()
		{
			objContractTypeDA = new ContractTypeDA();
		}
		#endregion

		#region ***** Get Methods ***** 
		/// <summary>
		/// Get ContractType by id
		/// </summary>
		/// <param name="id">ID</param>
		/// <returns>ContractType</returns>
		public ContractType GetByID(int id)
		{
			return objContractTypeDA.GetByID(id);
		}

		/// <summary>
		/// Get all of ContractType
		/// </summary>
		/// <returns>List<<ContractType>></returns>
		public List<ContractType> GetList()
		{
			string cacheName = "lstContractType";
			if( ServerCache.Get(cacheName) == null )
			{
				ServerCache.Insert(cacheName, objContractTypeDA.GetList(), "ContractType");
			}
			return (List<ContractType>) ServerCache.Get(cacheName);
		}

		/// <summary>
		/// Get DataSet of ContractType
		/// </summary>
		/// <returns>DataSet</returns>
		public DataSet GetDataSet()
		{
			string cacheName = "dsContractType";
			if( ServerCache.Get(cacheName) == null )
			{
				ServerCache.Insert(cacheName, objContractTypeDA.GetDataSet(), "ContractType");
			}
			return (DataSet) ServerCache.Get(cacheName);
		}


		/// <summary>
		/// Get all of ContractType paged
		/// </summary>
		/// <param name="recperpage">recperpage</param>
		/// <param name="pageindex">pageindex</param>
		/// <returns>List<<ContractType>></returns>
		public List<ContractType> GetListPaged(int recperpage, int pageindex)
		{
			return objContractTypeDA.GetListPaged(recperpage, pageindex);
		}

		/// <summary>
		/// Get DataSet of ContractType paged
		/// </summary>
		/// <param name="recperpage">recperpage</param>
		/// <param name="pageindex">pageindex</param>
		/// <returns>DataSet</returns>
		public DataSet GetDataSetPaged(int recperpage, int pageindex)
		{
			return objContractTypeDA.GetDataSetPaged(recperpage, pageindex);
		}





		#endregion

		#region ***** Add Update Delete Methods ***** 
		/// <summary>
		/// Add a new ContractType within ContractType database table
		/// </summary>
		/// <param name="obj_contracttype">ContractType</param>
		/// <returns>key of table</returns>
		public int Add(ContractType obj_contracttype)
		{
			ServerCache.Remove("ContractType", true);
			return objContractTypeDA.Add(obj_contracttype);
		}

		/// <summary>
		/// updates the specified ContractType
		/// </summary>
		/// <param name="obj_contracttype">ContractType</param>
		/// <returns></returns>
		public void Update(ContractType obj_contracttype)
		{
			ServerCache.Remove("ContractType", true);
			objContractTypeDA.Update(obj_contracttype);
		}

		/// <summary>
		/// Delete the specified ContractType
		/// </summary>
		/// <param name="id">ID</param>
		/// <returns></returns>
		public void Delete(int id)
		{
			ServerCache.Remove("ContractType", true);
			objContractTypeDA.Delete(id);
		}
		#endregion
	}
}
